package com.itheima.servise.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.EmpJobCountData;
import com.itheima.servise.EmpCountServise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EmpCountServiseImpl implements EmpCountServise {
    @Autowired
    private EmpMapper empMapper;
    @Override
    public EmpJobCountData countJob() {
        List<Map<String, Object>> maps = empMapper.countJob();
        EmpJobCountData empJobCountData = new EmpJobCountData();
        List<Object> jobList = maps.stream().map(m -> m.get("jobname")).toList();
        List<Object> DataList = maps.stream().map(m -> m.get("totals")).toList();
        empJobCountData.setJobList(jobList);
        empJobCountData.setDataList(DataList);
        return empJobCountData;


    }

    @Override
    public List<Map> countGender() {
        List<Map> maps = empMapper.countGender();
        return maps;
    }
}
